<?php
require_once 'Junction/Clause.php';

/**
 * Clause where each condition is AND'd together.
 *
 */
class Junction_Clause_Conjunction implements Junction_Clause {
	
	private $_conditions;
	private $_params;
	
	public function __construct() {
		$this->_conditions = array();
		$this->_params = array();
	}
	
	public function bindCondition($expression, $value = null) {
		$this->_conditions[] = $expression;
		if (isset($value)) {
			$this->_params[] = $value;
		}
	}
	
	/**
	 * @return String
	 */
	public function toSql() {
		$clause = implode($this->_conditions, ' AND ');
		return (strlen($clause) > 0) ? ' WHERE ' . $clause : '';
	}
	
	/**
	 * @return array
	 */
	public function getParameters() {
		return $this->_params;
	}
	
	/**
	 * @return String
	 */
	public function __toString() {
		return $this->toSql();
	}
}
?>